var $http = axios.create({
  baseURL: "http://localhost:3000",
});
var common = {
  activeIndex: "",
  // 目的地的 tabs
  tabs: [
    { text: "小区房源", url: "" },
    { text: "评论", url: "" },
    { text: "周边玩乐", url: "" },
    { text: "小区介绍", url: "" },
  ],
  getActiveIndex() {
    if (location.href.includes("fangyuan")) {
      common.activeIndex = 1;
    } else if (location.href.includes("pinglun")) {
      common.activeIndex = 2;
    } else if (location.href.includes("wanle")) {
      common.activeIndex = 3;
    } else if (location.href.includes("jieshao")) {
      common.activeIndex = 4;
    }
  },

  // 渲染底部
  renderFooter() {
    // 需要添加底部的页面
    var list = [
      "house.html",
      "target-fangyuan.html",
      "target-jieshao.html",
      "target-pinglun.html",
      "target-wanle.html",
      "my.html",
      "discover.html",
    ];
    list.forEach(function (item, index) {
      if (location.href.includes(item)) {
        $("body").append(`
           <ul class="footer fixed aic flex jc-sa">
            <a class="fdc aic ${
              item === "house.html" ? "active" : ""
            }" href="./house.html">
                <span class="iconfont f22 icon-shouye"></span>
                <span class="mt-5 f12">首页</span></a>
            <a class="fdc aic ${
              item.includes('target') ? "active" : ""
            }" href="target-fangyuan.html">
                <span class="iconfont f20 icon-map"></span>
                <span class="mt-5 f12">目的地</span>
            </a>
             <a class="fdc aic ${
               item === "demand.html" ? "active" : ""
             }" href="./demand.html">
                <span class="iconfont f22 base icon-htmal5icon18"></span>
                <span class="mt-5 f12">提交需求</span>
            </a>
             <a class="fdc aic ${
               item === "discover.html" ? "active" : ""
             }" href="discover.html">
                <span class="iconfont f22 icon-faxian"></span>
                <span class="mt-5 f12">发现</span>
            </a>
            <a class="fdc aic ${
              item === "my.html" ? "active" : ""
            }" href="./my.html">
                <span class="iconfont f22 icon-wode"></span>
                <span class="mt-5 f12">我的</span>
            </a>
        </ul>
        `);
      }
    });
  },
};

// 目的地的 tabs
common.getActiveIndex();
common.renderFooter();
